package patterns.transfer;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by lenovo on 2016/12/12 0012.
 * 业务对象类
 */
public class StudentBO {
    //列表充当数据库
    List<StudentVO> studentVOS;

    public StudentBO() {
        studentVOS = new ArrayList<>();
        StudentVO s1 = new StudentVO("jerry", 0);
        StudentVO s2 = new StudentVO("tom", 1);
        studentVOS.add(s1);
        studentVOS.add(s2);
    }

    public List<StudentVO> getAllStudents() {
        return studentVOS;
    }

    public StudentVO getStudent(int rollNo) {
        return studentVOS.get(rollNo);
    }

    public void updateStudent(StudentVO studentVO) {
        studentVOS.get(studentVO.getRollNo()).setName(studentVO.getName());
        System.out.println("更新了：" + studentVOS.get(studentVO.getRollNo()));
    }
}
